using System;
using Subsync.Core.Sync;
using Gtk;
using Gdk;

namespace Subsync.GUI
{
	/// <summary>
	/// Author: Juin Min
	/// </summary>
	public partial class SyncItem : Gtk.Button
	{
        //Class Variables
        private Gtk.Image syncicon;

        //Class Properties
        public Sync sync_info { get; set; }
        
        //Constructor
		public SyncItem (String sync_title)
		{
			sync_info = new Config ().LoadSync (sync_title);
			this.ButtonSetup ();
		}

		public SyncItem (Sync sync_obj)
		{
			sync_info = sync_obj;
			this.ButtonSetup ();
		}

		private void ButtonSetup ()
		{
			this.Relief = ReliefStyle.None;
			this.CanFocus = false;
			syncicon = new Gtk.Image ();
			syncicon.Pixbuf = new Gdk.Pixbuf (sync_info.icon);
			syncicon.Show ();
			this.Add (syncicon);
			this.HeightRequest = 128;
			this.WidthRequest = 128;
		}
		
		public void Refresh() {
			syncicon.Pixbuf = new Gdk.Pixbuf (sync_info.icon);
		}
		
		protected override void OnEntered ()
		{
			base.OnEntered ();
			GdkWindow.Cursor = new Gdk.Cursor(CursorType.Hand2);
		}

		protected override void OnLeft ()
		{
			base.OnLeft ();
			GdkWindow.Cursor = new Gdk.Cursor(CursorType.LeftPtr);
		}
	}
}
